package com.api.task.createtask;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import com.api.test.AbstractApiTest;
import com.zyncro.api.ITaskApiService;
import com.zyncro.api.exceptions.ZyncroApiException;
import com.zyncro.api.model.TaskApiType;
import com.zyncro.api.model.TaskStatusApiType;

@ContextConfiguration(locations = { "classpath:/task/task-context.xml" })
public class CreateTaskNotTaskManager extends AbstractApiTest {

	@Value("#{group_toCreate[notTaskManager].appId}")
	private String notTaskManagerUrn;

	@Value("#{group_toCreate[notTaskManager].password}")
	private String notTaskManagerPassword;

	@Value("#{group_toCreate.urn}")
	private String groupUrn;

	@Value("#{group_toCreate.eventUrn}")
	private String groupEventUrn;

	@BeforeClass
	protected void setParameters() throws Exception {

		getApi().login(notTaskManagerUrn, notTaskManagerPassword);
	}

	@Test(expectedExceptions = { ZyncroApiException.class })
	public void testCreateTask() throws ZyncroApiException {

		String title = "Titulo de tarea";
		String description = "Description";
		String responsible = null;
		String responsibleText = null;
		String dueDate = null;
		TaskApiType type = TaskApiType.TASK;
		TaskStatusApiType status = TaskStatusApiType.PENDING;
		String following = null;
		String threadUrn = null;

		getApi().getService(ITaskApiService.class).createTask(title, description, responsible, responsibleText, dueDate, type, status,
				following, groupUrn, threadUrn);
	}

	@Test(expectedExceptions = { ZyncroApiException.class })
	public void testCreateTaskThread() throws ZyncroApiException {

		String title = "Titulo de tarea";
		String description = "Description";
		String responsible = null;
		String responsibleText = null;
		String dueDate = null;
		TaskApiType type = TaskApiType.TASK;
		TaskStatusApiType status = TaskStatusApiType.PENDING;
		String following = null;

		getApi().getService(ITaskApiService.class).createTask(title, description, responsible, responsibleText, dueDate, type, status,
				following, groupUrn, groupEventUrn);
	}
}
